
package com.neighbor.neighborhoodadmin.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.neighbor.neighborhoodadmin.pojo.MallProductTypes;
import org.apache.ibatis.annotations.Select;
import java.util.List;


/**
 * <p>
 * 商品类型表 Mapper 接口
 * </p>
 *
 * @author song
 * @since 2025-09-22 09:11:23
 */

public interface IMallProductTypesDao extends BaseMapper<MallProductTypes> {

    @Select("SELECT * FROM mall_product_types WHERE status = 1 ORDER BY created_at DESC")
    List<MallProductTypes> selectActiveTypes();

    @Select("SELECT COUNT(*) FROM mall_products WHERE type_id = #{typeId}")
    Integer countProductsByType(Integer typeId);

    @Select("SELECT * FROM mall_product_types WHERE name LIKE CONCAT('%', #{keyword}, '%')")
    List<MallProductTypes> searchByName(String keyword);
}
